package com.house.building.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.house.building.entity.BuildEntity;
import com.house.building.service.BuildService;
import com.house.common.utils.PageUtils;
import com.house.common.utils.R;



/**
 * 
 *
 * @author breeze3
 * @email 3043401891@gmail.com
 * @date 2022-04-25 20:19:42
 */
@RestController
@RequestMapping("building/build")
public class BuildController {
    @Autowired
    private BuildService buildService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = buildService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{buildId}")
    public R info(@PathVariable("buildId") Integer buildId){
		BuildEntity build = buildService.getById(buildId);

        return R.ok().put("build", build);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BuildEntity build){
		buildService.save(build);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BuildEntity build){
		buildService.updateById(build);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] buildIds){
		buildService.removeByIds(Arrays.asList(buildIds));

        return R.ok();
    }

}
